import javax.swing.JOptionPane;

public class Start {

	public static void main(String Arg[]) {
		String className = JOptionPane.showInputDialog("Entre com o nome do Bean");

		BuildEntity builder = new BuildEntity();
		Entity entity = builder.build(className);
		
		if (generate(entity)) {
			JOptionPane.showMessageDialog(null, "Código Gerado com sucesso");
		}
	}
	
	public static Boolean generate(Entity entity) {
		if(entity.getDAO()){
			ClassDao dao = new ClassDao();			
			FileUtil.writeFile(dao.filePath(entity), dao.sourceCode(entity));
		}
		if(entity.getIEJB()){
			InterfaceEJB iEjb = new InterfaceEJB();			
			FileUtil.writeFile(iEjb.filePath(entity), iEjb.sourceCode(entity));
		}
		if(entity.getEJB()){
			ClassEJB ejb = new ClassEJB();			
			FileUtil.writeFile(ejb.filePath(entity), ejb.sourceCode(entity));
		}
		if(entity.getWRAPPER()){
			ClassWrapper wrapper = new ClassWrapper();			
			FileUtil.writeFile(wrapper.filePath(entity), wrapper.sourceCode(entity));
		}
		if(entity.getMB()){
			ClassMB mb = new ClassMB();			
			FileUtil.writeFile(mb.filePath(entity), mb.sourceCode(entity));
		}
		
		return Boolean.TRUE;
	}


}
